package com.itheima.goodsconsumer.service;

import com.itheima.goodsconsumer.model.Cart;
import com.itheima.goodsconsumer.model.Goods;
import com.itheima.goodsconsumer.model.Userorder;
import com.itheima.goodsconsumer.dao.CartDao;
import com.itheima.goodsconsumer.dao.GoodsDao;
import com.itheima.goodsconsumer.dao.OrderDao;
import com.itheima.goodsconsumer.dao.ShoppingDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
@Service
public class GoodsServiceImpl implements GoodsService{
    @Autowired
    CartDao cartDao;
    @Autowired
    GoodsDao goodsDao;
    @Autowired
    OrderDao orderDao;
    @Autowired
    ShoppingDao shoppingDao;

    @Override
    public List<Goods> getAllgoods() {
        return goodsDao.getAllgoods();
    }

    @Override
    public List<Goods> getOnegoods(String gname) {
        return goodsDao.getOnegoods(gname);
    }

//    @Override
//    public int paygoods(int gid, int gremain) {
//        return 0;
//    }

    @Override
    public List<Userorder> getAllorder(int uid) {
        return orderDao.getAllorder(uid);
    }

    @Override
    public Goods getOnegid(int gid) {
        return goodsDao.getOnegid(gid);
    }

    @Override
    public int insertOrder(String goodsname, Integer number,Integer price, Integer uid){
        return cartDao.insertOrder(goodsname,number,price,uid);
    }

    @Override
    public List<Cart> getAllcart(int uid) {
        return shoppingDao.getAllcart(uid);
    }

    @Override
    public int intcart(String goodsname, Integer number, Integer price, Integer goodid, Integer uid) {
        return shoppingDao.intcart(goodsname,number,price,goodid,uid);
    }

    @Override
    public int deleteCart(int gid) {
        return cartDao.deleteCart(gid);
    }

    @Override
    public int updateCart(int number, int id) {
        return shoppingDao.updateCart(number,id);
    }
}
